package com.shaoshaohuo.app.ui;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.constant.ExtraName;
import com.shaoshaohuo.app.entity.ExchangeRecord;
import com.shaoshaohuo.app.view.TopbarView;
import com.shaoshaohuo.app.utils.ImageLoadUtil;

public class PointExchangeDetailActivity extends BaseActivity{

	private TopbarView mTopbarView;

	private ImageView imageView;
	private TextView mGoodsTitleText;
	private TextView mPointText;
	
	private TextView mStatusText;
	private TextView mExchangeCountText;
	private TextView mNameText;
	private TextView mPhoneText;
	private TextView mAddressText;

	private ExchangeRecord pointGoods;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_point_exchange_detail);
		initData();
		initView();
		setUpView();
	}

	private void initData() {
		this.pointGoods = (ExchangeRecord) getIntent().getSerializableExtra(ExtraName.pointGoods);
	}

	private void initView() {
		mTopbarView = (TopbarView) this.findViewById(R.id.topbar);
		imageView = (ImageView) this.findViewById(R.id.imageview_car_user_headview);
		mGoodsTitleText = (TextView) this.findViewById(R.id.textview_car_username);
		mPointText = (TextView) this.findViewById(R.id.textview_car_phone);
		
		mStatusText = (TextView) this.findViewById(R.id.textview_status);
		mExchangeCountText = (TextView) this.findViewById(R.id.textview_count);
		mNameText = (TextView) this.findViewById(R.id.textview_name);
		mPhoneText = (TextView) this.findViewById(R.id.textview_phone);
		mAddressText = (TextView) this.findViewById(R.id.textview_address);
	}

	private void setUpView() {
		mTopbarView.setCenterText("兑换详情");
		mTopbarView.setLeftView(true, true);

		StringBuilder sb = new StringBuilder();
		
		switch (pointGoods.getStatus()) {
		case "3":
			sb.append("待发货");
			break;
		case "4":
			sb.append("已发货 ");
			break;
		case "5":
			sb.append("已签收 ");
			break;
		}
		if(pointGoods.getLogistics() != null){
			sb.append(pointGoods.getLogistics().getCompanyname()+" ");
			sb.append(pointGoods.getLogistics().getWaybill()+" ");
		}
		
//		LoadUtils.getInstance().loadImage(imageView, pointGoods.getGoodsinfo().getImg());
		ImageLoader.getInstance().displayImage(pointGoods.getGoodsinfo().getImg(), imageView,ImageLoadUtil.build);
		mGoodsTitleText.setText(pointGoods.getGoodsinfo().getTitle());
		mPointText.setText(pointGoods.getIntegraltotal()+"积分");
		
		mStatusText.setText(sb.toString());
		mExchangeCountText.setText("兑换数量:"+pointGoods.getNum());
		mNameText.setText("收货人:"+pointGoods.getContact());
		mPhoneText.setText("联系电话:"+pointGoods.getPhone());
		mAddressText.setText("收货地址:"+pointGoods.getAddress());
		
	}
	
}
